# -*- mode: python ; coding: utf-8 -*-
import os
from PyInstaller.utils.hooks import collect_data_files, collect_submodules, collect_dynamic_libs


binaries = collect_dynamic_libs('PyQt6')

datas = collect_data_files('PyQt6')
datas += collect_data_files('uiautomator2', include_py_files=False)

datas += [
    ('config/config.yaml', 'config'),             # 示例：配置文件
]
datas += collect_data_files("PyQt6.Qt6")

hiddenimports = collect_submodules('PyQt6')
hiddenimports += collect_submodules('pymongo')
hiddenimports += collect_submodules('bson')
hiddenimports += ['xhs.common_db']
hiddenimports += ['xhs.config']
hiddenimports += ['xhs.db_queue']
hiddenimports += ['xhs.device_manager']
hiddenimports += ['xhs.my_log']
hiddenimports += ['xhs.task_worker']
hiddenimports += ['xhs.ui']
hiddenimports += ['xhs.ui_signal']
hiddenimports += ['xhs.wifi']
hiddenimports += ['xhs.xhs_service']

a = Analysis(
    ['main.py'],
    pathex=['D:\\code\\PythonProject\\xhs_control'],
    binaries=binaries,
    datas=datas,
    hiddenimports=hiddenimports,
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    [('v', None, 'OPTION')],
    exclude_binaries=True,
    name='xhs_control',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=False, #压缩
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
coll = COLLECT(
    exe,
    a.binaries,
    a.datas,
    strip=False,
    upx=False, #压缩
    upx_exclude=[],
    name='xhs_control',
)

#exe = EXE(
#    pyz,
#    a.scripts,
#    [],                    # 这里原来写了 [('v', None, 'OPTION')]，去掉
#    exclude_binaries=False,  # onefile 模式不要排除二进制文件
#    name='xhs_control',
#    debug=False,
#    bootloader_ignore_signals=False,
#    strip=False,
#    upx=True,
#    console=True,
#    disable_windowed_traceback=False,
#    argv_emulation=False,
#    target_arch=None,
#    codesign_identity=None,
#    entitlements_file=None,
#    icon=None,
#    onefile=True,
#)


#exe = EXE(
#    pyz,
#    a.scripts,
#    [],
#    exclude_binaries=False,  # onefile 要包含所有二进制文件
#    name='main',
#    debug=False,
#    bootloader_ignore_signals=False,
#    strip=False,
#    upx=True,
#    console=True,
#    disable_windowed_traceback=False,
#    argv_emulation=False,
#    target_arch=None,
#    codesign_identity=None,
#    entitlements_file=None,
#    icon=None,
#    onefile=True,
#)

